<?php
/**
 * Created by PhpStorm.
 * User: fenfen
 * Date: 2016/12/27
 * Time: 11:03
 */

namespace bc\model;

use bc\ar\MActiveRecord;
class ProductsampleModel  extends MActiveRecord
{

    /**
     *
     */
    public static function tableName()
    {
        return '{{%product_sample}}';
    }
    
         /*
         * 获取产品列表
         */
        public function getProductInfo(){
            $this->columns = 'bc_product_sample.product_id , bc_product_sample.item_title';
           
            $ar = $this->find()->select( $this->columns );
            return $ar->asArray ()->all ();
        }
        
    
        
         public function getListById($id)
        {
           
            $ar = $this->find()->where(['bc_product_sample.product_id'=> $id]);
            return $ar->asArray()->One();
        }
        
        public function getPrimaryKeyByProductId($id) 
        {
            $sql = "SELECT `id` FROM `bc_product_sample`  WHERE  `product_id` = $id";

            $data = self::findBySql( $sql )->asArray()->one();
            //var_dump($data);die();
            return $data;
            
        }
        
}